package com.example.app.components.MyLazyColumn.MyPageLazyColumn

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.paging.CombinedLoadStates
import com.example.app.components.MyProgressIndicator.MyCircularProgressIndicator
import com.example.app.components.MyText.MyText
import com.example.app.ui.theme.my_description_color
import androidx.paging.LoadState

@Composable
fun MyPageLazyColumnBottom(loadState: CombinedLoadStates) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .height(60.dp),
        horizontalArrangement = Arrangement.Center,
        verticalAlignment = Alignment.CenterVertically
    ) {
        when (loadState.append) {
            LoadState.Loading -> {
                // 显示加载指示器
                MyCircularProgressIndicator(
                    strokeWidth = 2.dp,
                    modifier = Modifier.size(18.dp),
                    color = my_description_color
                )
            }

            is LoadState.Error -> {
                // 处理错误情况，例如显示重试按钮
                MyText(
                    "加载失败",
                    style = MaterialTheme.typography.bodySmall.copy(
                        color = my_description_color
                    )
                )
            }

            is LoadState.NotLoading -> {
                // 可选：当列表加载完成且没有更多数据时的处理
                MyText(
                    "没有更多了",
                    style = MaterialTheme.typography.bodySmall.copy(
                        color = my_description_color
                    )
                )
            }

            else -> {
            }
        }
    }
}